package com.jingdianjichi.club.oss.config;

import com.jingdianjichi.club.oss.adapter.StorageAdapter;
import com.jingdianjichi.club.oss.enums.OssTypeEnum;
import com.jingdianjichi.club.oss.adapter.AliStorageAdapter;
import com.jingdianjichi.club.oss.adapter.MinioStorageAdapter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 86156
 * @version 1.0
 * @date 2024-10-25 17:38
 */
@Configuration
@RefreshScope
public class StorageConfig {
    @Value("${storage.service.type}")
    private String storageType;

    @Bean
    @RefreshScope
    public StorageAdapter storageService(){
        if(OssTypeEnum.MINIO.name.equals(storageType)){
            return new MinioStorageAdapter();
        }else{
            return new AliStorageAdapter();
        }
    }
}
